Skip to content

Java: path sanitizer for replace, replaceAll, and matches #18646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jcogs33
Copy link
Contributor

@jcogs33 jcogs33 commented Jan 31, 2025

Description

Adds a path injection sanitizer for calls to replace, replaceAll, and matches that make sure /, \, .. are not in the path.

Consideration

  • This PR does not attempt to handle all possible regexes, but instead heuristically covers some common cases. Let me know if you want any adjustments to the heuristics applied.
  • Note that some of the QL is structured to optimize performance, such as the use of the predicates isReplaceTarget, isReplaceAllTarget, and isMatchesTarget.

@github-actions github-actions bot added the Java label Jan 31, 2025
@jcogs33 jcogs33 changed the title Java: path sanitizer for replace', replaceAll, and matches` Java: path sanitizer for replace, replaceAll, and matches Jan 31, 2025
@jcogs33 jcogs33 force-pushed the jcogs33/java/directory-chars-path-sanitizer branch from c33e03d to a88e541 Compare February 19, 2025 15:10
@jcogs33 jcogs33 force-pushed the jcogs33/java/directory-chars-path-sanitizer branch from 6b5cce0 to d0207c6 Compare March 10, 2025 03:24
@jcogs33 jcogs33 force-pushed the jcogs33/java/directory-chars-path-sanitizer branch from 17d20e6 to 41aeb87 Compare March 10, 2025 22:56
@jcogs33 jcogs33 marked this pull request as ready for review March 11, 2025 00:06
@jcogs33 jcogs33 requested a review from a team as a code owner March 11, 2025 00:06
@jcogs33 jcogs33 requested a review from owen-mc March 11, 2025 00:06
Copy link
Contributor

@owen-mc owen-mc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looking good. A few suggestions and one thing that I think is wrong.

@jcogs33 jcogs33 requested a review from owen-mc March 17, 2025 22:59
@jcogs33 jcogs33 merged commit 2750d1d into github:main Mar 18, 2025
15 checks passed
@jcogs33 jcogs33 deleted the jcogs33/java/directory-chars-path-sanitizer branch March 18, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants